﻿using System;

class SubsetSums
{
    static void Main(string[] args)
    {
        System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;

        long sumToSeachFor = long.Parse(Console.ReadLine());
        byte numbersToIterate = byte.Parse(Console.ReadLine());
        long[] numbersArray = new long[numbersToIterate];

        for (int i = 0; i < numbersToIterate; i++)
        {
            numbersArray[i] = long.Parse(Console.ReadLine());
        }

        int result = 0;

        int combinationsBitwiseMask = 0;
        for (int i = 0; i < numbersToIterate; i++)
        {
            combinationsBitwiseMask +=  (int)Math.Pow(2,i);

        }

        for (int currentCombination = combinationsBitwiseMask; currentCombination > 0; currentCombination--)
        {
            long sum = 0;

            for (int currentIndex = 0; currentIndex < numbersToIterate ; currentIndex++)
            {
                sum += numbersArray[currentIndex] * ((currentCombination >> currentIndex) & 1);
            }
          

            if( sum == sumToSeachFor)
            {
                result++;
            }
        }
        

        Console.WriteLine( result );
    }
}
